const { createGzip } = require('zlib')

const {createDeflate} = require('zlib')

module.exports=(rs,req,res)=>{
  const acceptEncoding = req.headers['accept-encoding']
  if(!acceptEncoding || acceptEncoding.match(/\b(gzip|deflate)\b/)){
    return rs;
  }else if( acceptEncoding.match( acceptEncoding.match(/\bdeflate\b/))){
    res.setHeader('Content-Encoding','deflate')
    return rs.pipe(createDeflate())
  }
}